package edu.xidian.sselab.cloudcourse.controller;

import edu.xidian.sselab.cloudcourse.domain.test7_entity;
import edu.xidian.sselab.cloudcourse.repository.test7_Repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class test7_controller {
    @Autowired
    private test7_Repository test7_repository;

    @RequestMapping("/test7")
    public String test7_try(Model model){ //要求7的controller
        model.addAttribute("title", "各系轿车每月销量走势");
        return "test7"; //跳转到test7页面
    }

    @RequestMapping("/test23")
    public @ResponseBody
    Map test7_try2() throws IOException { //要求7的controller

        String nation = "自主"; //车国别，车系，德系，法系，韩系，日系，美系，自主
        String start_time = "201907"; //开始时间
        String end_time = "202006"; //结束时间


        List<test7_entity> recordList2 = test7_repository.find("德系",start_time,end_time); //根据要求查找数据
        List<test7_entity> recordList3 = test7_repository.find("法系",start_time,end_time); //根据要求查找数据
        List<test7_entity> recordList4 = test7_repository.find("韩系",start_time,end_time); //根据要求查找数据
        List<test7_entity> recordList5 = test7_repository.find("日系",start_time,end_time); //根据要求查找数据
        List<test7_entity> recordList6 = test7_repository.find("美系",start_time,end_time); //根据要求查找数据
        List<test7_entity> recordList7 = test7_repository.find(nation,start_time,end_time); //根据要求查找数据
        Map<String,List> map=new HashMap<>();

        //map.put("车系",recordList1);
        map.put("德系",recordList2);
        map.put("法系",recordList3);
        map.put("韩系",recordList4);
        map.put("日系",recordList5);
        map.put("美系",recordList6);
        map.put("自主",recordList7);
        System.out.println("以下是201907到202006所有系的销售数据：");


        System.out.println(map);
        return map;
    }
}
